<template>
	<view class="uni-tab-bar">
		<scroll-view id="tab-bar" class="uni-swiper-tab" :class="type === 'uStyle'?'zc-swiper-tab':'tRight'" scroll-x :scroll-left="scrollLeft">
			<view v-for="(tab,index) in tabBars" :key="tab.id" class="swiper-tab-list " 
			:style="{'border-right':type === 'zcStyle'?'none':'','font-size':type === 'uStyle'?'26rpx':'24rpx'}" 
			:class="tabIndex!==index ? '' : type === 'uStyle'?'active' : 'zcActive'"
			 :id="tab.id" :data-current="index" @click="tapTab">{{tab.name}} <view class="count" v-if="tab.SelectNumber">{{tab.SelectNumber}}</view></view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		props:{
			tabIndex:{
				type:Number,
				default:0
			},
			tabBars:Array,
			type:{
				type:String,
				default:'uStyle'	//uStyle \ zcStyle
			}
		},
		data() {
			return {
				isClickChange: false,
				scrollLeft: 0
				
			};
		},
		onLoad() {
			
		},
		methods:{
			async tapTab(e) { //点击tab-bar
				let tabIndex = e.target.dataset.current;
				if (this.tabIndex === tabIndex) {
					return false;
				} else {
					this.$emit('tapTab',tabIndex)
				}
			}
		}
	}
</script>

<style>
	.uni-tab-bar-loading {
		text-align: center;
		font-size:32upx;
		color: #999;
	}
	.uni-swiper-tab{
		border-bottom: none;
		justify-content: space-between;
		line-height: 1;
		height: auto;
		box-sizing: border-box;
		margin-bottom: 20upx;
	}
	.zc-swiper-tab{
		border: 1upx solid #3ca4fa;
		border-radius: 10upx;
	}
	.swiper-tab-list{
		position: relative;
		padding: 6upx 10upx;
		border-right: 1upx solid #3ca4fa;
		width: 25%;
		box-sizing: border-box;
	}
	.swiper-tab-list:last-child{
		border-right: none;
	}
	.active{
		background-color: #3ca4fa;
		color: #FFFFFF!important;
	}
	.zcActive{
		/* border-bottom: 3upx solid #3ca4fa !important; */
		color: #3ca4fa!important;
		position: relative;
	}
		.zcActive:after{
			position: absolute;
			content: "";
			height: 5upx;
			width: 50upx;
			background:#3ca4fa ;
			left: 50%;
			margin-left: -25upx;
			bottom: 0;
		}
	.tRight{
		text-align: right;
	}
	
</style>
